package com.itheima.dao;

import com.itheima.pojo.OrderSetting;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.Date;
import java.util.List;
import java.util.Map;


@Mapper
public interface OrderSettingDao {


    /**
     * 根据预约时间查询是否存在预约
     * @param orderDate
     * @return
     */
    @Select("select count(*) from t_ordersetting where orderDate = #{orderDate}")
    Integer findCountByOrderDate(Date orderDate);


    /**
     * 根据预约时间修改预约人数
     * @param orderSetting
     */
    @Update("update t_ordersetting set number = #{number} where orderDate = #{orderDate}")
    void updateByOrderDate(OrderSetting orderSetting);

    /**
     * 添加预约
     * @param orderSetting
     */
    @Insert(" insert into t_ordersetting (orderDate, number, reservations) values (#{orderDate}, #{number}, #{reservations})")
    void add(OrderSetting orderSetting);

    /**
     * 根据年月查询对应的预约设置信息
     * @param map
     * @return
     */
    @Select("select * from t_ordersetting where orderDate between #{begin} and #{end}")
    List<OrderSetting> getOrderSettingByMonth(Map<String, Date> map);
}
